package com.icss.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.icss.entity.Address;

public interface AddressDao {
	@Insert("insert into address values(0,#{address_phone},#{address_name},#{address_detail},#{address_sex},#{c_id},#{address_default})")
	public int insertAddress(@Param("address_phone")String address_phone,@Param("address_name")String address_name,@Param("address_detail")String address_detail,@Param("address_sex")String address_sex,@Param("c_id")Integer c_id,@Param("address_default")boolean address_default);
	@Select("select * from address where c_id=#{c_id} ORDER BY address_default desc")
	public List<Address> findAddressByc_id(int c_id);
	@Update("update address set address_phone=#{ads_phone},address_name=#{ads_name},address_detail=#{ads_detail},address_sex=#{ads_sex},address_default=#{ads_default} where address_id=#{ads_id}")
	public int updateAddress(@Param("ads_phone")String ads_phone,@Param("ads_name")String ads_name,@Param("ads_detail")String ads_detail,@Param("ads_sex")String ads_sex,@Param("ads_default")boolean ads_default,@Param("ads_id")Integer ads_id);
//	更改默认地址
	@Update("update address set address_default=0 where c_id=#{c_id}")
	public int reDefault(Integer c_id);
	@Update("update address set address_default=1 where c_id=#{c_id} and address_id=#{address_id}")
	public int updateDefault(@Param("c_id")Integer c_id,@Param("address_id")Integer address_id);
	@Delete("delete from address where address_id=#{address_id}")
	public int delAds(Integer address_id);
}
